#include <iostream>
using namespace std;
#define int long long 
const int N = 100010;
int a[N];
signed main() { 
    int n;
    cin >> n;
    a[0] = 0;
    for(int i = 1; i <= n; i++) {
        int temp;
        cin >> temp;
        a[i] = a[i - 1] + temp;
    }
    int t;
    cin >> t;
    while(t--) {
        int x, y;
        cin >> x >> y;
        cout << a[y] - a[x - 1] << endl;
    }
    return 0;
}